#include "ELAPLA.h"
#include <string.h>

void ElasticParameter(Material *m)
{
    m->Elastic.K = m->Elastic.E / 3.0 / (1 - 2.0 * m->Elastic.u);
    m->Elastic.G = m->Elastic.E / 2.0 / (1 + m->Elastic.u);
}

bool MatrixD_R1D(Material *m, double a[MATRIX_ALLOCATE_SIZE])
{
   
    return false;
}

bool MatrixD_R2D(Material *m, double a[MATRIX_SIZE][MATRIX_SIZE])
{
    double K = 0.0, G = 0.0;
    ElasticParameter(m);

    K = m->Elastic.K;
    G = m->Elastic.G;

    a[0][0] = K + 4.0 / 3.0 * G;
    a[0][1] = K - 2.0 / 3.0 * G;
    a[0][2] = K - 2.0 / 3.0 * G;
    a[0][3] = 0.0;
    a[0][4] = 0.0;
    a[0][5] = 0.0;

    a[1][0] = K - 2.0 / 3.0 * G;
    a[1][1] = K + 4.0 / 3.0 * G;
    a[1][2] = K - 2.0 / 3.0 * G;
    a[1][3] = 0.0;
    a[1][4] = 0.0;
    a[1][5] = 0.0;

    a[2][0] = K - 2.0 / 3.0 * G;
    a[2][1] = K - 2.0 / 3.0 * G;
    a[2][2] = K + 4.0 / 3.0 * G;
    a[2][3] = 0.0;
    a[2][4] = 0.0;
    a[2][5] = 0.0;

    a[3][0] = 0.0;
    a[3][1] = 0.0;
    a[3][2] = 0.0;
    a[3][3] = 2.0 * G;
    a[3][4] = 0.0;
    a[3][5] = 0.0;

    a[4][0] = 0.0;
    a[4][1] = 0.0;
    a[4][2] = 0.0;
    a[4][3] = 0.0;
    a[4][4] = 2.0 * G;
    a[4][5] = 0.0;

    a[5][0] = 0.0;
    a[5][1] = 0.0;
    a[5][2] = 0.0;
    a[5][3] = 0.0;
    a[5][4] = 0.0;
    a[5][5] = 2.0 * G;
}